<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
$servername = "192.168.68.140";
$username = "root";
$password = "root";
$dbname = "test";

// Create connection
$con = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}
    $sql = "select * from detail where name<>\"总金额\" and name<>\"订单数量\";";

$result = mysqli_query($con,$sql);

//定义变量json存储值
$array= array();
class emp{
    public $name;
    public $value;
}
while ($row = mysqli_fetch_row($result))
{
    list($name,$value) = $row;
    $em = new emp();
    $em->name = $name;
    $em->value = $value;

    //数组赋值
    $array[] = $em;
}

echo json_encode($array);
?>